package com.wenx;

import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public abstract class AbstractTreeSorts implements TreeSorts {

    List<Integer> result = new ArrayList<>();

    protected TreeNode root = new TreeNode();

    protected void setData() {
        ArrayList<Integer> list = Lists.newArrayList(34, 523, 12, 42, 53, 103, 582, 134, 591, 923);

        list.forEach(i -> SetTreeData.insert(root,i));
    }

    @Override
    public List<Integer> getSorted() {
        if(result.size() > 0) {
            return result.stream().sorted(Comparator.comparingInt(Integer::intValue).reversed())
                    .collect(Collectors.toList());
        }
        return result;
    }

}
